Improve checksum verification for plugins without main PHP files#143
Merged
Conversation
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix verification checks for plugins missing main PHP file
Fix plugin verification to detect directories without main PHP files
Nov 1, 2025
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
swissspidy
reviewed
Dec 12, 2025
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
swissspidy
reviewed
Dec 12, 2025
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Pull request overview
This PR fixes a security vulnerability where wp plugin verify-checksums would skip plugin directories that lack valid main PHP files, allowing malware to hide undetected in these "shadow" directories. The fix enhances plugin detection to scan the filesystem for all plugin directories and verify them against WordPress.org checksums, regardless of whether they have valid plugin headers.
Changes:
- Enhanced
get_all_plugin_names()to scan the filesystem for all plugin directories, not just those with valid headers, with security measures including symlink exclusion - Modified
UnfilteredPlugin::get()to detect plugin directories even when main files are missing - Added
detect_version_from_directory()fallback method to find version information from any PHP file in a plugin directory
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/WP_CLI/Fetchers/UnfilteredPlugin.php | Adds fallback logic to detect plugin directories without main files by checking filesystem directly |
| src/Checksum_Plugin_Command.php | Enhances plugin detection with filesystem scanning, adds version detection fallback, includes security measures and user warnings |
| features/checksum-plugin.feature | Adds test scenario for verifying plugins with missing/renamed main files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
swissspidy
reviewed
May 27, 2026
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes security issue where
wp plugin verify-checksumsskipped plugin directories without valid main plugin files, allowing malware to hide in these "shadow" directories.Changes
1. Enhanced Plugin Detection (
get_all_plugin_names())2. Enhanced Plugin Fetcher (
UnfilteredPlugin::get())realpath()validation3. Version Detection Fallback (
fetch_version_from_wp_org())WpOrgApi::get_plugin_info()to get the current stable versionfalse(skips verification) if the plugin is not found on WordPress.org or the API call fails4. User Warnings
5. Test Coverage
--versionflag for single-plugin verification--allflag scenariosSecurity Impact
Before: Attackers could hide malicious files in plugin directories by removing/renaming the main plugin file. These directories were completely ignored during checksum verification.
After: All plugin directories are verified against WordPress.org checksums, regardless of whether they have valid plugin headers. Malware cannot hide using this technique.
Usage Note
When a plugin's main file is missing and the version cannot be determined, the command automatically queries WordPress.org for the current stable version and verifies against that. You can also explicitly provide the version using the
--versionflag:Backward Compatibility
✅ Fully backward compatible - existing plugins with valid headers work exactly as before
✅ Only affects detection of plugin directories without valid main files (previously ignored)
✅ No breaking changes to API or command syntax
Files Changed
src/Checksum_Plugin_Command.phpsrc/WP_CLI/Fetchers/UnfilteredPlugin.phpfeatures/checksum-plugin.featureOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.